﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace form
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click_1(object sender, EventArgs e)
        {
            Console.WriteLine("输入数据为：");
        }
        int[] a = new int[9];

        private void shuZu1_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[0] = int.Parse(button.Text);
            }
                

        }

        private void button_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;
            

            //最大值，最小值
            int j;
            int max = a[0];
            int min = a[0];
            for (j = 0; j <= 8; j++)
            {
                if (max < a[j])
                {
                    max = a[j];
                }
                if (min > a[j])
                {
                    min = a[j];
                }
            }
            maxBox.Text = max.ToString();
            minBox.Text = min.ToString();

            //求和
            int sum=0;
            if(shuZu1==null)
            {
                sum = 0;
            }
            else
            {
                
                for ( int i = 0; i < a.Length; i++)
                {
                    sum += a[i];
                }
            }
            sumBox.Text = sum.ToString();

            //平均值
            float eve;
            if (sum==0)
            {
                eve = 0;
            }
            else
            {
                eve = sum / a.Length;
            }
            eveBox.Text = eve.ToString();

        }

        private void shuZu2_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[1] = int.Parse(button.Text);
            }
        }

        private void shuZu3_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[2] = int.Parse(button.Text);
            }
        }

        private void shuZu4_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[3] = int.Parse(button.Text);
            }
        }

        private void shuZu5_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[4] = int.Parse(button.Text);
            }
        }

        private void shuZu6_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[5] = int.Parse(button.Text);
            }
        }

        private void shuZu7_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[6] = int.Parse(button.Text);
            }
        }

        private void shuZu8_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[7] = int.Parse(button.Text);
            }
        }

        private void shuZu9_TextChanged(object sender, EventArgs e)
        {
            TextBox button = sender as TextBox;
            if (button.Text != null)
            {

                a[8] = int.Parse(button.Text);
            }
        }

        private void maxBox_TextChanged(object sender, EventArgs e)
        {
            int max;

        }

        private void eveBox_TextChanged(object sender, EventArgs e)
        {
            int eve;
        }

        private void minBox_TextChanged(object sender, EventArgs e)
        {
            int min;
        }

        private void sumBox_TextChanged(object sender, EventArgs e)
        {
            int sum;
        }
    }
}
